.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "CBC\-N1QLBACK" "1" "July 2015" "" ""
.
.SH "NAME"
\fBcbc\-n1qlback\fR \- Stress Test for Couchbase Query (N1QL)
.
.SH "SYNOPSIS"
\fBcbc\-pillowfight\fR \-f QUERYFILE [\fIOPTIONS\fR]
.
.SH "DESCRIPTION"
\fBcbc\-n1qlback\fR creates a specified number of threads each executing a set of user defined queries\.
.
.P
\fBcbc\-n1qlback\fR requires that it be passed the path to a file containing the queries to execute; one per line\. The query should be in the format of the actual HTTP POST body (in JSON format) to be sent to the server\. For simple queries, only the \fBstatement\fR field needs to be set:
.
.IP "" 4
.
.nf

{"statement":"SELECT country FROM `travel\-sample`"}
{"statement":"SELECT country, COUNT(country) FROM `travel\-sample` GROUP BY country"}
.
.fi
.
.IP "" 0
.
.P
For more complex queries (for example, placeholders, custom options), you may refer to the N1QL REST API reference\.
.
.P
\fBn1qlback\fR requires that any resources (data items, indexes) are already defined\.
.
.SH "OPTIONS"
The following options control workload generation:
.
.TP
\fB\-f\fR \fB\-\-queryfile\fR=\fIPATH\fR
Path to a file containing the query bodies to execute in JSON format, one query per line\. See above for the format\.
.
.TP
\fB\-t\fR, \fB\-\-num\-threads\fR=\fINTHREADS\fR
Set the number of threads (and thus the number of client instances) to run concurrently\. Each thread is assigned its own client object\.
.
.P
The following options control how \fBcbc\-n1qlback\fR connects to the cluster
.
.TP
\fB\-U\fR, \fB\-\-spec\fR=\fISPEC\fR
A string describing the cluster to connect to\. The string is in a URI\-like syntax, and may also contain other options\. See the \fIEXAMPLES\fR section for information\. Typically such a URI will look like \fBcouchbase://host1,host2,host3/bucket\fR\.
.
.IP
The default for this option is \fBcouchbase://localhost/default\fR
.
.TP
\fB\-u\fR, \fB\-\-username\fR=\fIUSERNAME\fR
Specify the \fIusername\fR for the bucket\. As of Couchbase Server 2\.5 this field should be either left empty or set to the name of the bucket itself\.
.
.TP
\fB\-P\fR, \fB\-\-password\fR=\fISASLPASS\fR:

.
.TP
\fB\-P \-\fR, \fB\-\-password=\-\fR
Specify the SASL password for the bucket\. This is only needed if the bucket is protected with a password\. Note that this is \fInot\fR the administrative password used to log into the web interface\.
.
.IP
Specifying the \fB\-\fR as the password indicates that the program should prompt for the password\. You may also specify the password on the commandline, directly, but is insecure as command line arguments are visible via commands such as \fBps\fR\.
.
.TP
\fB\-T\fR, \fB\-\-timings\fR
Dump command timings at the end of execution\. This will display a histogram showing the latencies for the commands executed\.
.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Specify more information to standard error about what the client is doing\. You may specify this option multiple times for increased output detail\.
.
.TP
\fB\-D\fR, \fB\-\-cparam\fR=OPTION=VALUE
Provide additional client options\. Acceptable options can also be placed in the connection string, however this option is provided as a convenience\. This option may be specified multiple times, each time specifying a key=value pair (for example, \fB\-Doperation_timeout=10 \-Dconfig_cache=/foo/bar/baz\fR)\. See \fIADDITIONAL OPTIONS\fR for more information
.
.P
 \fI\fR
.
.SH "ADDITIONAL OPTIONS"
The following options may be included in the connection string (via the \fB\-U\fR option) as URI\-style query params (e\.g\. \fBcouchbase://host/bucket?option1=value1&option2=value2\fR) or as individual key=value pairs passed to the \fB\-D\fR switch (e\.g\. \fB\-Doption1=value1 \-Doption2=value\fR)\. The \fB\-D\fR will internally build the connection string, and is provided as a convenience for options to be easily passed on the command\-line
.
.TP
\fBoperation_timeout=SECONDS\fR
Specify the operation timeout in seconds\. This is the time the client will wait for an operation to complete before timing it out\. The default is \fB2\.5\fR
.
.TP
\fBconfig_cache=PATH\fR
Enables the client to make use of a file based configuration cache rather than connecting for the bootstrap operation\. If the file does not exist, the client will first connect to the cluster and then cache the bootstrap information in the file\.
.
.TP
\fBcertpath=PATH\fR
The path to the server\'s SSL certificate\. This is typically required for SSL connectivity unless the certificate has already been added to the openssl installation on the system (only applicable with \fBcouchbases://\fR scheme)
.
.TP
\fBssl=no_verify\fR
Temporarily disable certificate verification for SSL (only applicable with \fBcouchbases://\fR scheme)\. This should only be used for quickly debugging SSL functionality\.
.
.TP
\fBsasl_mech_force=MECHANISM\fR
Force a specific \fISASL\fR mechanism to be used when performing the initial connection\. This should only need to be modified for debugging purposes\. The currently supported mechanisms are \fBPLAIN\fR and \fBCRAM\-MD5\fR
.
.TP
\fBbootstrap_on=<both,http,cccp>\fR
Specify the bootstrap protocol the client should use when attempting to connect to the cluster\. Options are: \fBcccp\fR: Bootstrap using the Memcached protocol (supported on clusters 2\.5 and greater); \fBhttp\fR: Bootstrap using the HTTP REST protocol (supported on any cluster version); and \fBboth\fR: First attempt bootstrap over the Memcached protocol, and use the HTTP protocol if Memcached bootstrap fails\. The default is \fBboth\fR
.
.SH "EXAMPLES"
The following will create a file with 3 queries and 5 threads alternating between them\. It also creates indexes on the \fBtravel\-sample\fR bucket
.
.IP "" 4
.
.nf

cbc n1ql \-U couchbase://192\.168\.72\.101/a_bucket \'CREATE INDEX ix_name ON `travel\-sample`(name)\'
cbc n1ql \-U couchbase://192\.168\.72\.101/a_bucket \'CREATE INDEX ix_country ON `travel\-sample`(country)\'

cat queries\.txt <<EOF
{"statement":"SELECT country FROM `travel\-sample` WHERE `travel\-sample`\.country = \e"United States\e""}
{"statement":"SELECT name FROM `travel\-sample` LIMIT 10"}
{"statement":"SELECT country, COUNT(country) FROM `travel\-sample` GROUP BY country"}
EOF

cbc\-n1qlback \-U couchbase://192\.168\.72\.101/a_bucket \-t 5 \-f queries\.txt
.
.fi
.
.IP "" 0
.
.SH "BUGS"
This command\'s options are subject to change\.
.
.SH "SEE ALSO"
cbc(1), cbc\-pillowfight(1), cbcrc(4)
.
.SH "HISTORY"
The \fBcbc\-n1qlback\fR tool was first introduced in libcouchbase 2\.4\.10
